//
//  AddDescriptionCell.m
//  MIDI
//
//  Created by 邵子凡 on 15/11/4.
//  Copyright © 2015年 QXSX. All rights reserved.
//

#import "AddDescriptionCell.h"

@interface AddDescriptionCell ()<UITextViewDelegate>

@property (weak, nonatomic) IBOutlet UITextView *textView;
@property (copy, nonatomic) NSString *placeHolder;
@end

@implementation AddDescriptionCell

+(instancetype)cellWithTableView:(UITableView *)tableView{
    
    static NSString *ID = @"AddDescriptionCell";
    
    AddDescriptionCell  *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    if (cell == nil) {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"AddDescriptionCell" owner:nil options:nil]firstObject] ;
    }
    
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    
    return cell;
}

- (void)awakeFromNib {
    
    self.textView.delegate = self;
    self.placeHolder = @"请描述你的问题";
    
    //设置textView边框及边颜色
    self.textView.layer.borderColor = [UIColor colorWithRed:176 / 255.0 green:177 / 255.0 blue:178 / 255.0 alpha:1].CGColor;
    self.textView.layer.borderWidth = 0.5;
    
}

- (void)textViewDidBeginEditing:(UITextView *)textView{
    
    self.textView.text = @"";
}

- (void)textViewDidEndEditing:(UITextView *)textView{
    
    if ([textView.text isEqualToString:@""]){
        textView.text = self.placeHolder;
    }
    
    if ([self.delegate respondsToSelector:@selector(uploadAddDescription:)]) {
        
        [self.delegate uploadAddDescription:textView.text];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
